package com.my.aslife.controller;

import com.my.aslife.module.common.ErrorCode;
import com.my.aslife.module.common.ResponseResult;
import com.my.aslife.module.entity.dtos.TxMoneyDto;
import com.my.aslife.service.TxMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mayuan
 * @description TODO
 */
@RestController
@RequestMapping("/api/my/txmoney")
public class TxMoneyController {

    @Autowired
    private TxMoneyService txMoneyService;

    @PostMapping("/withdraw/deposit")
    public ResponseResult onWithdrawDeposit(@RequestBody TxMoneyDto txMoneyDto){
        if(txMoneyDto.getPhone() == null || txMoneyDto.getMoney() == null
                || txMoneyDto.getMoney() <= 0 || txMoneyDto.getMoney() % 5 != 0) {
            return ResponseResult.failed(ErrorCode.FAIL_SYSTEM);
        }
        return txMoneyService.onWithdrawDeposit(txMoneyDto);
    }

}
